home *** CD-ROM | disk | FTP | other *** search
/ Programming Languages Suite / ProgramD2.iso / Borland / Borland C++ V5.02 / VIEWEX.PAK / VIEWEX.CPP < prev    next >
C/C++ Source or Header  |  1997-05-06  |  4KB  |  131 lines

  1. // viewex.cpp : Defines the class behaviors for the application.
  2. //
  3. // This is a part of the Microsoft Foundation Classes C++ library.
  4. // Copyright (C) 1992-1995 Microsoft Corporation
  5. // All rights reserved.
  6. //
  7. // This source code is only intended as a supplement to the
  8. // Microsoft Foundation Classes Reference and related
  9. // electronic documentation provided with the library.
  10. // See these sources for detailed information regarding the
  11. // Microsoft Foundation Classes product.
  12.  
  13. #include "stdafx.h"
  14. #include "viewex.h"
  15.  
  16. #include "splitter.h"
  17.  
  18. #ifdef _DEBUG
  19. #undef THIS_FILE
  20. static char BASED_CODE THIS_FILE[] = __FILE__;
  21. #endif
  22.  
  23. /////////////////////////////////////////////////////////////////////////////
  24. // CViewExApp
  25.  
  26. BEGIN_MESSAGE_MAP(CViewExApp, CWinApp)
  27.     //{{AFX_MSG_MAP(CViewExApp)
  28.     ON_COMMAND(ID_APP_ABOUT, OnAppAbout)
  29.     //}}AFX_MSG_MAP
  30.     ON_COMMAND(ID_FILE_NEW, CWinApp::OnFileNew)
  31.     ON_COMMAND(ID_FILE_OPEN, CWinApp::OnFileOpen)
  32. END_MESSAGE_MAP()
  33.  
  34. /////////////////////////////////////////////////////////////////////////////
  35. // CViewExApp construction
  36. // Place all significant initialization in InitInstance
  37.  
  38. CViewExApp::CViewExApp()
  39. {
  40. }
  41.  
  42. /////////////////////////////////////////////////////////////////////////////
  43. // The one and only CViewExApp object
  44.  
  45. CViewExApp NEAR theApp;
  46.  
  47. /////////////////////////////////////////////////////////////////////////////
  48. // CViewExApp initialization
  49.  
  50. BOOL CViewExApp::InitInstance()
  51. {
  52.     // Standard initialization
  53.     Enable3dControls();
  54.  
  55.     // This VIEWEX sample shows several techniques for creating CView
  56.     //  derived classes.   All the views in this sample use the same
  57.     //  CMainDoc class.  For simplicity the CMainDoc class does not
  58.     //  support serialization, but has a very simple data model of
  59.     //  a single string and an RGB color.  We register different
  60.     //  document templates for each of the interesting view types.
  61.  
  62.     // simple text output view
  63.     AddDocTemplate(new CMultiDocTemplate(IDR_TEXTTYPE,
  64.             RUNTIME_CLASS(CMainDoc),
  65.             RUNTIME_CLASS(CMDIChildWnd),
  66.             RUNTIME_CLASS(CTextView)));
  67.  
  68.     // simple color output view
  69.     //   a doc template with no 'fileNewName' so it is not a choice for FileNew
  70.     AddDocTemplate(new CMultiDocTemplate(IDR_COLORTYPE,
  71.             RUNTIME_CLASS(CMainDoc),
  72.             RUNTIME_CLASS(CMDIChildWnd),
  73.             RUNTIME_CLASS(CColorView)));
  74.  
  75.     // form view with input
  76.     AddDocTemplate(new CMultiDocTemplate(IDR_INPUTTYPE,
  77.             RUNTIME_CLASS(CMainDoc),
  78.             RUNTIME_CLASS(CMDIChildWnd),
  79.             RUNTIME_CLASS(CInputView)));
  80.  
  81.     // splitter frame with both simple text output and form input view
  82.     AddDocTemplate(new CMultiDocTemplate(IDR_SPLIT2TYPE,
  83.             RUNTIME_CLASS(CMainDoc),
  84.             RUNTIME_CLASS(CSplitterFrame),
  85.             RUNTIME_CLASS(CTextView)));
  86.  
  87.     // 3-way splitter frame with form input, text output and color output views
  88.     AddDocTemplate(new CMultiDocTemplate(IDR_SPLIT3TYPE,
  89.             RUNTIME_CLASS(CMainDoc),
  90.             RUNTIME_CLASS(C3WaySplitterFrame),
  91.             RUNTIME_CLASS(CInputView)));
  92.  
  93.     // create main MDI Frame window
  94.     // Please note that for simple MDI Frame windows with no toolbar,
  95.     //   status bar or other special behavior, the CMDIFrameWnd class
  96.     //   can be used directly for the main frame window just as the
  97.     //   CMDIChildWnd can be use for a document frame window.
  98.  
  99.     CMDIFrameWnd* pMainFrame = new CMDIFrameWnd;
  100.     if (!pMainFrame->LoadFrame(IDR_MAINFRAME))
  101.         return FALSE;
  102.  
  103.     // Also in this example, there is only one menubar shared between
  104.     //  all the views.  The automatic menu enabling support of MFC
  105.     //  will disable the menu items that don't apply based on the
  106.     //  currently active view.  The one MenuBar is used for all
  107.     //  document types, including when there are no open documents.
  108.  
  109.     // Now finally show the main menu
  110.     pMainFrame->ShowWindow(m_nCmdShow);
  111.     pMainFrame->UpdateWindow();
  112.     m_pMainWnd = pMainFrame;
  113.  
  114.     #ifndef _MAC
  115.     // command line arguments are ignored, create a new (empty) document
  116.     OnFileNew();
  117.     #endif
  118.  
  119.     return TRUE;
  120. }
  121.  
  122. /////////////////////////////////////////////////////////////////////////////
  123. // CViewExApp commands
  124.  
  125. void CViewExApp::OnAppAbout()
  126. {
  127.     CDialog(IDD_ABOUTBOX).DoModal();
  128. }
  129.  
  130. /////////////////////////////////////////////////////////////////////////////
  131.